Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | ACADEMIC RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * PROJECT METADATA8 * -----------------------------------------------------------------------------9 * Project : UQO Éval10 * File : src/app/a-vendre/[uid]/page.tsx11 * Module : app12 * Repository : https://git.spboucher.ai/uqo-eval13 * Project Website : https://www.uqo-eval.app14 * Created : 2026-10-0215 * Last Modified : 2026-10-0216 *17 * =============================================================================18 * SOFTWARE MAINTAINER & AFFILIATION19 * =============================================================================20 *21 * Maintainer : Simon-Pierre Boucher22 * Position : Professor of Finance23 * Institution : Université du Québec en Outaouais (UQO)24 * Department : Département des sciences administratives25 * Website : https://spboucher.ai26 * Git : https://git.spboucher.ai27 *28 * Research Contact : research@spboucher.ai29 * Direct Contact : simon@spboucher.ai30 * Security/Admin : admin@spboucher.ai31 *32 * The affiliation is descriptive. It is not an institutional endorsement,33 * a license grant or a determination of ownership.34 *35 * =============================================================================36 * COPYRIGHT, AUTHORSHIP & DATA37 * =============================================================================38 *39 * Copyright (c) the author(s) of this work.40 * Ownership is not asserted by this notice; see the repository records.41 *42 * This header identifies the maintainer of the software. Scientific43 * authorship of any associated paper is stated in the paper itself and44 * is not changed by this notice. Datasets and third-party materials45 * remain the property of their respective owners and licensors.46 *47 * This file is governed by the applicable project license, copyright48 * notices, institutional agreements and relevant law.49 *50 * =============================================================================51 * LICENSE & MAINTENANCE52 * =============================================================================53 *54 * License : None specified (no license file in this repository)55 * Classification : Public56 *57 * =============================================================================58 * END OF SP BOUCHER SOURCE HEADER59 * =============================================================================60 */6162// UQO Éval — laboratoire pédagogique d'évaluation immobilière63// Fiche complète d'une propriété à vendre (copie Immo-Ka) + mesure UQO Éval.64import type { Metadata } from "next";65import { cache } from "react";66import { notFound } from "next/navigation";67import { getUnit } from "@/lib/db";68import { getListing, listingsNear } from "@/lib/immoka";69import ListingView, { type ListingPageData } from "@/components/avendre/ListingView";70import { moneyFr } from "@/lib/seo";71import { summaryForListing } from "@/lib/cost/ai/service";7273export const dynamic = "force-dynamic";7475const load = cache((uid: string): ListingPageData | null => {76 const det = getListing(uid);77 if (!det) return null;78 const l = det.listing;79 const u = det.eval?.unit_id ? getUnit(det.eval.unit_id) : undefined;80 const nearby =81 l.lat != null && l.lng != null82 ? listingsNear(l.lat, l.lng, 3, { group: det.group, excludeUid: uid, limit: 6 })83 : [];84 return {85 listing: {86 uid: l.uid,87 source: l.source,88 url: l.url,89 title: l.title,90 address: l.address,91 sector: l.sector,92 city: l.city,93 region: l.region,94 propertyType: l.property_type,95 price: l.price,96 bedrooms: l.bedrooms,97 bathrooms: l.bathrooms,98 powderRooms: l.powder_rooms,99 areaSqft: l.area_sqft,100 lotSqft: l.lot_sqft,101 yearBuilt: l.year_built,102 mls: l.mls,103 brokerName: l.broker_name,104 agency: l.agency,105 description: l.description,106 lat: l.lat,107 lng: l.lng,108 firstSeen: l.first_seen,109 lastSeen: l.last_seen,110 },111 group: det.group,112 images: det.images,113 features: det.features,114 details: det.details,115 priceLog: det.priceLog,116 eval: det.eval,117 unit: u118 ? {119 id: u.id_provinc,120 adresse: u.adresse,121 apt: u.apt,122 municipalite: u.municipalite,123 typeProp: u.type_prop,124 anneeConstruction: u.annee_construction,125 aireEtagesM2: u.aire_etages_m2,126 superficieTerrainM2: u.superficie_terrain_m2,127 nbEtages: u.nb_etages,128 nbLogements: u.nb_logements,129 genreConstruction: u.genre_construction,130 lienPhysique: u.lien_physique,131 valeurTerrain: u.valeur_terrain,132 valeurBatiment: u.valeur_batiment,133 valeurRole: u.valeur_role,134 est2026: u.est_2026,135 p10: u.p10,136 p90: u.p90,137 history: ([2021, 2022, 2023, 2024, 2025, 2026] as const).map((y) => ({138 year: y,139 value: u[`est_${y}`] as number | null,140 })),141 }142 : null,143 nearby,144 aiSummary: safeSummary(uid),145 };146});147148/** Résumé de l'analyse IA du bâtiment (chantier Coût) — jamais bloquant pour la fiche. */149function safeSummary(uid: string) {150 try { return summaryForListing(uid); } catch { return null; }151}152153export async function generateMetadata({ params }: { params: Promise<{ uid: string }> }): Promise<Metadata> {154 const { uid } = await params;155 const d = load(decodeURIComponent(uid));156 if (!d) return { title: "Propriété introuvable" };157 const l = d.listing;158 const where = [l.address, l.city].filter(Boolean).join(", ") || l.title || "Propriété à vendre";159 const est = d.eval?.est ? ` · estimation UQO Éval ${moneyFr(d.eval.est)}` : "";160 const title = `${where} — ${moneyFr(l.price)}${est}`;161 const description = `${l.propertyType ?? "Propriété"} à vendre à ${l.city ?? "—"} : prix demandé ${moneyFr(162 l.price163 )}${d.eval?.est ? `, estimation UQO Éval ${moneyFr(d.eval.est)} (${moneyFr(d.eval.low)} – ${moneyFr(d.eval.high)})` : ""}. Choisissez vos comparables et comparez votre évaluation à la mesure du laboratoire.`;164 return {165 title,166 description,167 alternates: { canonical: `/a-vendre/${encodeURIComponent(l.uid)}` },168 openGraph: { title, description, type: "website", images: d.images[0] ? [{ url: d.images[0] }] : undefined },169 robots: { index: false, follow: true }, // annonces éphémères, contenu tiers170 };171}172173export default async function ListingPage({ params }: { params: Promise<{ uid: string }> }) {174 const { uid } = await params;175 const data = load(decodeURIComponent(uid));176 if (!data) notFound();177 return <ListingView data={data} />;178}179